/* ************************************************************************** */^M
/* Example of a syndication feed reader using the Project Rome API with       */^M
/* BSF4ooRexx                                                                 */^M
/* current version of Rome: rome1.0.jar            https://rome.dev.java.net/ */^M
/* You need to implement this API plus the JDOM API                           */^M
/* jdom.jar  ,   you can find this at               https://jdom.org/        ; */^M
/*                                                                            */^M
/* This class retrieves a syndfeed from the web and converts it to a chosen   */^M
/* rss type. Finally the feed is printed to the system  (in combination with  */^M
/* a grafical interface)                                                      */                        ^M
/* created by Martin Stoppacher     date:   26.12.2009    (c) 2009            */^M
/* license:ÊÊÊÊLGPL 3.0ÊÊÊÊÊÊÊused versions: Java 1.6, ooRexx 4.0, Bsf4ooRexx */^M
/*             (Lesser Gnu Public License version 3.0),                       */^M
/*             cf. <http://www.gnu.org/licenses/lgpl.html>                    */^M
/* ************************************************************************** */^M
^M
/* graphical part of the eaxample                                             */^M
frame=.bsf~new("java.awt.Frame", "Please enter the url")^M
frame~bsf.addEventListener( 'window', 'windowClosing', 'call BSF "exit"')^M
frame~setLayout( .bsf~new("java.awt.FlowLayout") )^M
^M
tf=.bsf~new("java.awt.TextField", "http://rss.orf.at/fm4.xml", 50)^M
^M
type=.bsf~new("java.awt.TextField", "rss_2.0", 50)^M
^M
but=.bsf~new('java.awt.Button', 'retrieve feed')^M
but~bsf.addEventListener('action', '', ' call text tf,type ')^M
^M
lable1=.bsf~new('java.awt.Label', "Feed URL:") ^M
lable2=.bsf~new('java.awt.Label', "Feed Type:")^M
^M
frame~add(lable1)^M
frame~add(tf)^M
frame~add(lable2)^M
frame~add(type)^M
frame~add(but)^M
^M
frame~~pack~~show~~toFront^M
do forever^M
INTERPRET .bsf~bsf.pollEventText^M
if result="SHUTDOWN, REXX !" then leave^M
end^M
exit^M
^M
text: --procedure^M
use arg tf,type     ^M
say hello this reads a syndfeed^M
--say please type in the url^M
^M
url= tf~getText                 /* you can use:  "http://rss.orf.at/fm4.xml"  */^M
typet= type~getText^M
^M
/*   this part is using the ROME API                                          */^M
^M
feedUrl=.bsf~new("java.net.URL", url)^M
say connecting__ || feedUrl~getAuthority()^M
^M
call Syssleep 1^M
^M
input=.bsf~new("com.sun.syndication.io.SyndFeedInput")^M
xmlr=.bsf~new("com.sun.syndication.io.XmlReader", feedUrl)^M
feed=input~build(xmlr)^M
^M
feed~setFeedType(typet)               /* This line retrieves the current type */^M
/* the default formats in ROME are: rss_0.90, rss_0.91, rss_0.92,             */^M
/* rss_0.93, rss_0.94, rss_1.0 rss_2.0 or atom_0.3                            */^M
^M
output=.bsf~new("com.sun.syndication.io.SyndFeedOutput")^M
say output~outputString(feed) ^M
^M
say feed~getFeedType()^M
say "------"^M
say done^M
^M
do forever^M
INTERPRET .bsf~bsf.pollEventText^M
end^M
^M
::requires BSF.cls